package cn.wangsy.zhidao;

public class Rectangle {

	private int width,height;
	
	public static void main(String[]args){
		Rectangle r1 = Rectangle.parse("30,20");
		System.out.printf("面积=%d,周长=%d",r1.getArea(),r1.getPeremeter());
	}
	
	public int getArea(){
		return width*height;
	}
	
	public int getPeremeter(){
		return 2*(width + height);
	}
	
	public Rectangle(int width,int height){
		this.width = width;
		this.height = height;
	}
	
	public static Rectangle parse(String size){
		String[]sizes = size.split(",");
		return new Rectangle(Integer.parseInt(sizes[0]), Integer.parseInt(sizes[1]));
	}
	
}
